home *** CD-ROM | disk | FTP | other *** search
- %%HP: T(3)A(D)F(.);
- "**********************
- * Name: Line
- * draw/clear/toggle
- * line in a GROB
- * Interface:
- * gr #x1 #y1 #x2 #y2
- * -->
- * #x1 must be < #x2.
- * Error Exits: none
- * Alters:
- * CPU - A,B,C,D,D0,
- * D1,R0,R1,R2,R3,R4,
- * P,CRY
- * RAM - gr and coord.
- * popped
- * Calls:
- * =POP# =SAVPTR
- * =PopASavptr
- * =GETPTRLOOP
- * Stk Levels:
- * 1
- * Notes:
- * std. DDA
- * The routine works
- * only on VDISP yet,
- * assuming x-size =
- * 131 (real 136 ->
- * 34 nibb/line).
- * !!! BANG TYPE !!!
- * History:
- * 05/20/92 DM
- * Implemented as
- * test for QIX. Q&D!
- * 07/11/92 DM
- * review, add spec.
- * cases, cond.ass.
- **********************
-
- Toggle EQU 0 Set only
- On EQU 0 one to 1
- Off EQU 1 at a time!
-
- sFlag EQU 5
-
- *****
- * Pop parameter,calc.
- * and check dx
- *****
- GOSUB Pop#
- R3=A y2
- GOSUB Pop#
- R2=A x2
- GOSUB Pop#
- R1=A y1
- GOSUB Pop#
- R0=A x1
- *1* GOSBVL =PopASavptr ->grob
-
- GOSBVL =SAVPTR *1*
- D0=(5) =VDISP *1* ->->grob
- A=DAT0 A *1* ->grob
-
- D0=A ->grob
-
- A=R0 x1
- C=R2 x2
- C=C-A A dx=x2-x1
- GONC dxok
- GOTO Exit Sorry,invalid order
- dxok R2=C dx
-
- *****
- * Calculate ystep,
- * pointer to grob and
- * initial bit mask
- *****
- D0=D0+ 15 ->x, Skip prlg,len,y
- *2* C=DAT0 A x
- *2* C=C+CON A,7 Force byte boundary
- *2* CSRB.F A
- *2* CSRB.F A
- *2* CSRB.F A
- *2* C=C+C A nibb/line
- LC(5) 34 *2* nibb/line
-
- D=C A ys
- D0=D0+ 5 ->pix,Skip x
- A=R1 y1
-
- * unsigned C*=A (org.HP)
-
- B=0 A
- BCEX A
- Mul2 B=B-1 P
- GOC Mul3
- C=C+A A
- GOTO Mul2
- Mul3 ASL A
- P=P+1
- ?P# 5
- GOYES Mul2
- P= 0
-
- A=R0 x1,y1*nibb/line
- ASRB.F A
- ASRB.F A /=4
- A=A+C A offs=x1/4+y1*nibb/line
-
- CD0EX ->pix
- C=C+A A +=offs
-
- D0=C ->nibb
- * Now some magic
- A=R0 x1
- LC(1) 3
- C=C&A B x1%4
- C=C+CON B,13 +=13
- P=C 0
- LC(4) #1248
- P=C 0
- C=P 1
- P= 0
- B=C B mask
-
- IFNE Off
- B=-B-1 B OFF mask
- ENDIF
-
- *****
- * Calculate dy, check
- * for special cases
- * dx=0,dy=0 or dx=dy
- *****
- A=R1 y1
- C=R3 y2
- C=C-A A dy=y2-y1
- GONC tstdxy
- D=-D A -ys
- C=-C A -dy
- tstdxy
- ST=0 sFlag
- A=R2 dx
-
- ?C=A A
- GOYES dxeqdy dx=dy
- ?A=0 A
- GOYES dxeq0 dx=0
- ?C#0 A
- GOYES dxgtdy? dy<>0
-
- * dy=0,set up x steps
- D1=A cnt = dx
- GONC dx1dy0 BET
-
- * dx=0,set up y steps
- dxeq0
- ST=1 sFlag
- D1=C cnt=dy
- dx1dy0
- A=0 A
- A=A+1 A dx=1
- C=0 A dy=0
- GONC dxdycok BET
-
- * dx=dy,set up x&y steps
- dxeqdy
- D1=A cnt=dx
- A=0 A dx=0
- C=0 A dy=0
- GOC dxdycok BET
-
- Exit GOVLNG =GETPTRLOOP
-
- *****
- * Normal case, check
- * for dy>=dx, calc. e
- *****
- dxgtdy?
- ?C<A A
- GOYES dxdyok
-
- ST=1 sFlag dy>dx,swap dx, dy
- ACEX A
-
- dxdyok
- D1=A cnt=dx
-
- dxdycok
- R2=A dx
- R3=C dy
-
- ASRB.F A dx/2
- R4=A e
-
- *****
- * The show begins...
- *****
- plot A=DAT0 1 Read nibble
-
- IFNE On
- A=A!B B Set bit
- ENDIF
- IFNE Off
- A=A&B B Clear bit
- ENDIF
- IFNE Toggle
- C=A B
- A=A!B B
- C=C&B B
- A=A-C B
- ENDIF
-
- DAT0=A 1 Write nibble
-
- D1=D1- 1 --cnt
- GOC Exit
-
- A=R4.F A e
- C=R3.F A dy
- A=A+C A e+=dy
- R4=A.F A e
- C=R2.F A dx
-
- ?ST=1 sFlag
- GOYES allwy
-
- ?A<C A
- GOYES xstep e>=dx
-
- A=A-C A e-=dx
- R4=A.F A e
- CD0EX ->pix
- C=C+D A ->next row
- D0=C ->pix
-
- xstep
- B=B+B B mask<<=1
- IFNE (On)+(Toggle)
- GONC plot
- LC(2) #11 init.mask
- ENDIF
- IFNE Off
- GOC plot
- LC(2) #EE
- ENDIF
- B=C B mask
- D0=D0+ 1 ->nxt nibb
- GONC plot BET
-
- allwy
- ?A<C A
- GOYES ystep e>=dx
-
- A=A-C A e-=dx
- R4=A.F A e
-
- B=B+B B mask <<= 1
- IFNE (On)+(Toggle)
- GONC ystep
- LC(2) #11 init. mask
- ENDIF
- IFNE Off
- GOC ystep
- LC(2) #EE
- ENDIF
- B=C B mask
- D0=D0+ 1 ->nxt nibb
-
- ystep
- CD0EX ->pix
- C=C+D A ->next row
- D0=C ->pix
- GOTO plot
-
- Pop# GOVLNG =POP#"